package com.base;

import java.io.IOException;

import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import com.method.KmMethod;

public class Km extends Com<KmMethod> {
	
	@Override
	protected void reg() {
		Runtime rt = Runtime.getRuntime();
		try {
			rt.exec(Base.PATH + "nircmd32/nircmd.exe elevate regsvr32 /s "+Base.PATH +"kmlSdk/regkml.bat");
			System.out.println("reg km success！");
		} catch (Exception e) {
			try {
				rt.exec(Base.PATH + "nircmd64/nircmd.exe elevate regsvr32 /s "+Base.PATH +"kmlSdk/regkml.bat");
			} catch (IOException e1) {
				System.out.println("reg km fail！");
			}
		}

	}

	@Override
	protected String setComName() {
		return "MCUAPP.KML";
	}

	/**
	 * 键鼠调用
	 * 
	 * @param method 方法名
	 * @param params 参数
	 * @return
	 */
	public String call(KmMethod method, Object... params) {
		Variant call = null;
		if(params!=null&&params.length>0) {
			call = Dispatch.call(com, method.name(), params);
		}else {
			call = Dispatch.call(com, method.name());
		}
		return call.toString();
	}

}
